package com.example.controller;


import com.example.common.result.Result;
import com.example.entity.mes.Sked;
import com.example.entity.mes.SkedEquipment;
import com.example.entity.mes.SkedMaintain;
import com.example.service.SkedEquipmentService;
import com.example.service.SkedMaintainService;
import com.example.service.SkedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin // 跨域
@RestController
@RequestMapping("/api/Sked")
@Api(tags = "点检保养计划控制器")
public class SkedController {

    @Resource
    private SkedService skedService;
    @Resource
    private SkedEquipmentService skedEquipmentService;
    @Resource
    private SkedMaintainService skedMaintainService;

    @PostMapping("/queryIPageList")
    @ResponseBody
    @ApiOperation("点检保养分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "type", value = "类型", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "status", value = "状态", dataType = "Integer", dataTypeClass = Integer.class)
    })
    public Result querySkedIPageList(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, String code, String name, String type,Integer status){
        return this.skedService.querySkedIPageList(current,size,code,name,type,status);
    }

    @GetMapping("/querySkedinById/{id}")
    @ResponseBody
    @ApiOperation("项目计划通过id进行详细查询")
    public Result querySkedinById(@PathVariable Long id){
        return this.skedService.querySkedinById(id);
    }

    @PostMapping("/insertSked")
    @ResponseBody
    @ApiOperation("项目计划新增")
    public Result insertMaintain(@RequestBody Sked sked){
        return this.skedService.insertSked(sked);
    }

    @PutMapping("/updateSked")
    @ResponseBody
    @ApiOperation("项目计划修改")
    public Result updateMaintain(@RequestBody Sked sked){
        return this.skedService.updateSked(sked);
    }

    @DeleteMapping("/deleteSked/{id}")
    @ResponseBody
    @ApiOperation("项目计划物理删除")
    public Result deleteMaintain(@PathVariable Long id){
        return this.skedService.deleteSked(id);
    }

    @ApiOperation("项目计划批量物理删除/也可单物理删除")
    @DeleteMapping("/deleteSkedBatch/{ids}")
    public Result deleteSkedBatch(@PathVariable List<Integer> ids) {
        return this.skedService.deleteSkedBatch(ids);
    }

    @ApiOperation("skedEquipment中间表批量新增")
    @PostMapping("/insertskedEquipmentBatch")
    public Result insertBatch(@RequestBody List<SkedEquipment> skedEquipment) {
        return this.skedEquipmentService.insertskedEquipmentBatch(skedEquipment);
    }

    @ApiOperation("批量对skedEquipment中间表进行物理删除/也可单物理删除")
    @DeleteMapping("/deleteSkedEqBatch/{idlist}")
    public Result deleteSkedEqBatch(@PathVariable List<Integer> idlist) {
        return this.skedEquipmentService.deleteSkedEqBatch(idlist);
    }

    @ApiOperation("skedMaintain中间表批量新增")
    @PostMapping("/insertskedMaintainBatch")
    public Result insertskedMaintainBatch(@RequestBody List<SkedMaintain> skedMaintains) {
        return this.skedMaintainService.insertskedMaintainBatch(skedMaintains);
    }

    @ApiOperation("批量对skedMaintain中间表进行物理删除/也可单物理删除")
    @DeleteMapping("/deleteskedMaintainBatch/{idlist}")
    public Result deleteSkedMaintainBatch(@PathVariable List<Integer> idlist) {
        return this.skedMaintainService.deleteSkedMaintainBatch(idlist);
    }
}
